<template>
  <div id="admin">
    <el-container>
      <el-header class="layout-header">
        <h1>星光书城后台管理系统</h1>
      </el-header>
      <el-container class="layout-body">
        <el-aside class="layout-aside">
          <el-menu
              router
              :default-active="$router.currentRoute.path"
              class="el-menu-vertical-demo"
              background-color="#545c64"
              text-color="#fff"
              active-text-color="#ffd04b"
              @select="handleSelect"
          >
            <!-- 首页 -->
            <el-menu-item index="/admin-list">
              <i class="el-icon-s-home"></i>
              <span>首页</span>
            </el-menu-item>
            <!-- 分类页面 -->
            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-s-data"></i>
                <span>分类管理</span>
              </template>
              <el-menu-item index="/admin-add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加分类</span>
              </el-menu-item>
              <el-menu-item index="/admin/category-list">
                <i class="el-icon-s-operation"></i>
                <span>分类列表</span>
              </el-menu-item>
            </el-submenu>
            <!-- 轮播图管理 -->
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-picture"></i>
                <span>轮播图管理</span>
              </template>
              <el-menu-item index="/admin/banner-add-new">
                <i class="el-icon-circle-plus"></i>
                <span slot="title">添加轮播图</span>
              </el-menu-item>
              <el-menu-item index="/admin/banner-list">
                <i class="el-icon-s-operation"></i>
                <span slot="title">轮播图列表</span>
              </el-menu-item>
            </el-submenu>
            <!-- 销量榜单管理 -->
              <el-submenu index="4">
                <template slot="title">
                  <i class="el-icon-shopping-cart-2"></i>
                  <span>销量榜单管理</span>
                </template>
                <el-menu-item index="/admin/week-hot">
                  <i class="el-icon-data-analysis"></i>
                  <span>本周热卖榜单</span>
                </el-menu-item>
                <el-menu-item index="/admin/month-hot">
                  <i class="el-icon-data-analysis"></i>
                  <span>本月热卖榜单</span>
                </el-menu-item>
              </el-submenu>
            <!-- 图书管理 -->
              <el-submenu index="5">
                <template slot="title">
                  <i class="el-icon-reading"></i>
                  <span>图书管理</span>
                </template>
                <el-menu-item index="/admin/book-list">
                  <i class="el-icon-s-operation"></i>
                  <span>图书列表</span>
                </el-menu-item>
                <el-menu-item index="/admin/book-add-new">
                  <i class="el-icon-circle-plus"></i>
                  <span>添加图书</span>
                </el-menu-item>
              </el-submenu>
            <!-- 订单管理 -->
              <el-submenu index="6">
                <template slot="title">
                  <i class="el-icon-s-order"></i>
                  <span>订单管理</span>
                </template>
                <el-menu-item index="/admin/order-list">
                  <i class="el-icon-s-operation"></i>
                  <span>订单列表</span>
                </el-menu-item>
              </el-submenu>
            <!-- 公告管理 -->
              <el-submenu index="7">
                <template slot="title">
                  <i class="el-icon-edit-outline"></i>
                  <span>公告管理</span>
                </template>
                <el-menu-item index="/admin/notice-list">
                  <i class="el-icon-s-operation"></i>
                  <span>公告信息</span>
                </el-menu-item>
                <el-menu-item index="6-2">
                  <i class="el-icon-circle-plus"></i>
                  <span>添加公告</span>
                </el-menu-item>
              </el-submenu>
          </el-menu>
        </el-aside>
        <el-main class="layout-main">
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>

export default {
data(){
  return{

  }
},
  methods:{
    handleSelect(key,keyPath){
      console.log(key);
      if (key=='2-1'){
        let name = prompt("请输入分类的名称");
        //点击取消
        if (name==null){
          return;
        }
        if (name==''){
          this.$message.error("分类名称不能为空");
          return;
        }
        //发出添加分类的请求

        }else if (key=='6-2'){
        console.log(key);
          let name = prompt("请输入公告内容");
          //点击取消
          if (name==null){
            return;
          }
          if (name==''){
            this.$message.error("分类名称不能为空");
            return;
          }
          //发出添加分类的请求
      else {
          this.currentIndex = key;}}
    }

  },
}
</script>

<style>
#admin{
}
.layout-header{
  background-color: #15a0cd;
}
.layout-body{
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;
}
.layout-aside{
  background-color: rgb(84, 92, 100);
  width: 190px !important;
}

</style>
